package com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers;

import android.content.Context;
import android.util.Log;

import com.nickstumpos.android.GmailWidgetPlus.Constants.GMWP_Constants;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels.fourbyone.skins.FourByOneDTGraphiteManager;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels.fourbyone.skins.FourByOneSimpleManager;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels.twobytwo.skins.TwoByTwoClassicManager;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels.twobytwo.skins.TwoByTwoDTGraphiteManager;
import com.nickstumpos.android.GmailWidgetPlus.widget.presentation.managers.displaylabels.twobytwo.skins.TwoByTwoSimpleManager;
import com.nickstumpos.android.GmailWidgetPlus.widget.sizes.WidgetSize;
import com.nickstumpos.android.GmailWidgetPlus.widget.skins.WidgetSkins;

public class WidgetManagerFactory {

	public static WidgetUIManager getWidgetUIManager(final Context context,
			final int widgetId,
			final String account,
			final WidgetSize size) {

		final WidgetSkins type = WidgetSkins.valueOf(context.getSharedPreferences(GMWP_Constants.GMW_PREFS_REF,
				0)
				.getString(GMWP_Constants.WIDGET_SKIN + widgetId,
						WidgetSkins.TWO_BY_TWO_SIMPLE.toString()));
		Log.i("GMWP",
				"Creating widget Manager for id: " + String.valueOf(widgetId)
						+ " with the skin: "
						+ type.toString());
		WidgetUIManager ret = null;
		switch (type) {
			case TWO_BY_TWO_CLASSIC:
				ret = TwoByTwoClassicManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case TWO_BY_TWO_DTGRAPHITE:
				ret = TwoByTwoDTGraphiteManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case TWO_BY_TWO_SIMPLE:
				ret = TwoByTwoSimpleManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case FOUR_BY_ONE_DTGRAPHITE:
				ret = FourByOneDTGraphiteManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case FOUR_BY_ONE_SIMPLE:
				ret = FourByOneSimpleManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case ONE_BY_ONE_LABEL:
				ret = TwoByTwoSimpleManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			case ONE_BY_ONE_NO_LABEL:
				ret = TwoByTwoSimpleManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
			default:
				ret = TwoByTwoClassicManager.create(context,
						widgetId,
						type,
						account,
						size);
				break;
		}
		return ret;
	}
}
